package com.ruoyi.edge.gateway.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.gateway.domain.CollectSource;
import com.ruoyi.edge.gateway.service.CollectSourceService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 采集数据源
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/collectSource")
public class CollectSourceController extends BaseController {

    private final CollectSourceService collectSourceService;

    /**
     * 获取列表
     */
    @SaCheckPermission("edge:collectSource:listPage")
    @GetMapping("/listPage")
    public TableDataInfo<CollectSource> listPage(CollectSource collectSource, PageQuery pageQuery) {
        return collectSourceService.listPage(collectSource, pageQuery);
    }

    /**
     * 下拉参数获取
     */
    @SaCheckPermission("edge:collectSource:list")
    @GetMapping("/list")
    public R<List<CollectSource>> list(CollectSource collectSource) {
        return collectSourceService.list(collectSource);
    }

    /**
     * 获取详情
     */
    @SaCheckPermission("edge:collectSource:get")
    @GetMapping("/get")
    public R<CollectSource> get(String id) {
        return collectSourceService.get(id);
    }

    /**
     * 新增
     */
    @SaCheckPermission("edge:collectSource:add")
    @PostMapping("add")
    public R<String> add(@RequestBody CollectSource collectSource) {
        return collectSourceService.add(collectSource);
    }

    /**
     * 编辑
     */
    @SaCheckPermission("edge:collectSource:edit")
    @PutMapping("edit")
    public R<String> edit(@RequestBody CollectSource collectSource) {
        return collectSourceService.edit(collectSource);
    }

    /**
     * 删除
     */
    @SaCheckPermission("edge:collectSource:remove")
    @DeleteMapping("remove")
    public R<String> remove(String id) {
        return collectSourceService.remove(id);
    }

}
